#include "Scene.h"

namespace DYEngine
{
	Scene::Scene()
	{
		name = "New Scene";
		mRootNode.SetName("RootNode");

		GameObject* camNode = new GameObject("Camera");
		mCamera = new Camera(CameraType::Proj);
		camNode->AddComponent(mCamera);
		AddNode(camNode);
		Camera::SetMainCamera(mCamera);
	}

	Scene::Scene(const std::string& pName) : name(pName)
	{
		mRootNode.SetName("RootNode");

		GameObject* camNode = new GameObject("Camera");
		mCamera = new Camera(CameraType::Proj);
		camNode->AddComponent(mCamera);
		AddNode(camNode);
		Camera::SetMainCamera(mCamera);
	}

	Scene::~Scene()
	{
		
	}

	void Scene::AddNode(GameObject* pNode)
	{
		if (pNode == nullptr)
		{
			printf("Scene::AddNode pNode is nullptr \n");
			return;
		}

		pNode->SetParent(&mRootNode);
		mRootNode.AddChild(pNode);
	}

	static Scene* sCurrScene = nullptr;

	void Scene::SetCurrentScene(Scene* pScene)
	{
		sCurrScene = pScene;
	}

	Scene* Scene::GetCurrentScene()
	{
		return sCurrScene;
	}
}